/*
 * jxSwing Project (2012, 2013, 2014)
 * by Denilson Edinaldo Pinto
 * LGPL
 * Copyright (C) 2014
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Lesser General Public License for more details.
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */
package org.jxSwing.laf;

import javax.swing.UIDefaults;
import javax.swing.border.Border;
import javax.swing.border.CompoundBorder;
import javax.swing.border.LineBorder;
import javax.swing.plaf.BorderUIResource;
import javax.swing.plaf.ColorUIResource;
import javax.swing.plaf.FontUIResource;
import javax.swing.plaf.basic.BasicBorders;
import javax.swing.plaf.metal.DefaultMetalTheme;
import javax.swing.plaf.metal.MetalLookAndFeel;
import javax.swing.plaf.metal.MetalTheme;

/**
 * @author Denilson Edinaldo Pinto
 * @porject jxSwing
 * @package org.jxSwing.laf
 * @date 19/07/2014 - 11:52:40
 */
public final class JXMetalLookAndFeel extends LookAndFeelUtil {
	
	private static final MetalTheme DEFAULT_THEME = MetalLookAndFeel.getCurrentTheme();
	
	/**
	 * @return Classes
	 */
	public MetalTheme[] getThemeClasses() {
	
		return new MetalTheme[]{new Aqua(), new Charcoal(), new Contrast(), new Default(), new Emerald(), new Ruby(), new Steel()};
	}
	
	/**
	 * This class describes a theme using "blue-green" colors.
	 * 
	 * @author Steve Wilson
	 */
	public final class Aqua extends DefaultMetalTheme {
		
		private final ColorUIResource primary1 = new ColorUIResource(102, 153, 153);
		
		private final ColorUIResource primary2 = new ColorUIResource(128, 192, 192);
		
		private final ColorUIResource primary3 = new ColorUIResource(159, 235, 235);
		
		@Override
		protected ColorUIResource getPrimary1() {
		
			return primary1;
		}
		
		@Override
		protected ColorUIResource getPrimary2() {
		
			return primary2;
		}
		
		@Override
		protected ColorUIResource getPrimary3() {
		
			return primary3;
		}
		
		@Override
		public String getName() {
		
			return Aqua.class.getSimpleName();
		}
		
	}
	
	/**
	 * This class describes a theme using gray colors.
	 * 
	 * @author Steve Wilson
	 */
	public class Charcoal extends DefaultMetalTheme {
		
		private final ColorUIResource black = new ColorUIResource(222, 222, 222);
		
		private final ColorUIResource primary1 = new ColorUIResource(66, 33, 66);
		
		private final ColorUIResource primary2 = new ColorUIResource(90, 86, 99);
		
		private final ColorUIResource primary3 = new ColorUIResource(99, 99, 99);
		
		private final ColorUIResource secondary1 = new ColorUIResource(0, 0, 0);
		
		private final ColorUIResource secondary2 = new ColorUIResource(51, 51, 51);
		
		private final ColorUIResource secondary3 = new ColorUIResource(102, 102, 102);
		
		private final ColorUIResource white = new ColorUIResource(0, 0, 0);
		
		@Override
		protected ColorUIResource getBlack() {
		
			return black;
		}
		
		@Override
		protected ColorUIResource getPrimary1() {
		
			return primary1;
		}
		
		@Override
		protected ColorUIResource getPrimary2() {
		
			return primary2;
		}
		
		@Override
		protected ColorUIResource getPrimary3() {
		
			return primary3;
		}
		
		@Override
		protected ColorUIResource getSecondary1() {
		
			return secondary1;
		}
		
		@Override
		protected ColorUIResource getSecondary2() {
		
			return secondary2;
		}
		
		@Override
		protected ColorUIResource getSecondary3() {
		
			return secondary3;
		}
		
		@Override
		protected ColorUIResource getWhite() {
		
			return white;
		}
		
		@Override
		public String getName() {
		
			return Charcoal.class.getSimpleName();
		}
		
	}
	
	/**
	 * This class describes a higher-contrast Metal Theme.
	 * 
	 * @author Michael C. Albers
	 */
	public final class Contrast extends DefaultMetalTheme {
		
		private final ColorUIResource primary1 = new ColorUIResource(0, 0, 0);
		
		private final ColorUIResource primary2 = new ColorUIResource(204, 204, 204);
		
		private final ColorUIResource primary3 = new ColorUIResource(255, 255, 255);
		
		private final ColorUIResource primaryHighlight = new ColorUIResource(102, 102, 102);
		
		private final ColorUIResource secondary2 = new ColorUIResource(204, 204, 204);
		
		private final ColorUIResource secondary3 = new ColorUIResource(255, 255, 255);
		
		@Override
		protected ColorUIResource getPrimary1() {
		
			return primary1;
		}
		
		@Override
		protected ColorUIResource getPrimary2() {
		
			return primary2;
		}
		
		@Override
		protected ColorUIResource getPrimary3() {
		
			return primary3;
		}
		
		@Override
		protected ColorUIResource getSecondary2() {
		
			return secondary2;
		}
		
		@Override
		protected ColorUIResource getSecondary3() {
		
			return secondary3;
		}
		
		@Override
		public void addCustomEntriesToTable(final UIDefaults table) {
		
			final Border blackLineBorder = new BorderUIResource(new LineBorder(getBlack()));
			
			final Object textBorder = new BorderUIResource(new CompoundBorder(blackLineBorder, new BasicBorders.MarginBorder()));
			
			table.put("ToolTip.border", blackLineBorder);
			table.put("TitledBorder.border", blackLineBorder);
			
			table.put("TextField.border", textBorder);
			table.put("PasswordField.border", textBorder);
			table.put("TextArea.border", textBorder);
			table.put("TextPane.border", textBorder);
			table.put("EditorPane.border", textBorder);
			
		}
		
		@Override
		public ColorUIResource getAcceleratorForeground() {
		
			return getBlack();
		}
		
		@Override
		public ColorUIResource getAcceleratorSelectedForeground() {
		
			return getWhite();
		}
		
		@Override
		public ColorUIResource getControlHighlight() {
		
			return super.getSecondary3();
		}
		
		@Override
		public ColorUIResource getFocusColor() {
		
			return getBlack();
		}
		
		@Override
		public ColorUIResource getHighlightedTextColor() {
		
			return getWhite();
		}
		
		@Override
		public ColorUIResource getMenuSelectedBackground() {
		
			return getBlack();
		}
		
		@Override
		public ColorUIResource getMenuSelectedForeground() {
		
			return getWhite();
		}
		
		@Override
		public String getName() {
		
			return Contrast.class.getSimpleName();
		}
		
		@Override
		public ColorUIResource getPrimaryControlHighlight() {
		
			return primaryHighlight;
		}
		
		@Override
		public ColorUIResource getTextHighlightColor() {
		
			return getBlack();
		}
		
	}
	
	/**
	 * This class describes a theme using red colors.
	 * 
	 * @project UtilsClasses
	 * @author Denilson Edinaldo Pinto
	 * @date 16/11/2011
	 */
	public final class Default extends DefaultMetalTheme {
		
		private final ColorUIResource acceleratorForeground = DEFAULT_THEME.getAcceleratorForeground();// Pri
																										// 1
		
		private final ColorUIResource acceleratorSelectedForeground = DEFAULT_THEME.getAcceleratorSelectedForeground();// getBlack()
		
		private final ColorUIResource control = DEFAULT_THEME.getControl();// Sec 3
		
		private final ColorUIResource controlDarkShadow = DEFAULT_THEME.getControlDarkShadow();// Sec
																								// 1
		
		private final ColorUIResource controlDisabled = DEFAULT_THEME.getControlDisabled();// Sec 2
		
		private final ColorUIResource controlHighlight = DEFAULT_THEME.getControlHighlight();// getWhite()
		
		private final ColorUIResource controlInfo = DEFAULT_THEME.getControlInfo();// getBlack()
		
		private final ColorUIResource controlShadow = DEFAULT_THEME.getControlShadow();// Sec 2
		
		private final ColorUIResource controlTextColor = DEFAULT_THEME.getControlTextColor();// getControlInfo()
		
		private final FontUIResource controlTextFont = DEFAULT_THEME.getControlTextFont();
		
		private final ColorUIResource desktopColor = DEFAULT_THEME.getDesktopColor();// Pri 2
		
		private final ColorUIResource focusColor = DEFAULT_THEME.getFocusColor();// Pri 2
		
		private final ColorUIResource highlightedTextColor = DEFAULT_THEME.getHighlightedTextColor();// getControlTextColor()
		
		private final ColorUIResource inactiveControlTextColor = DEFAULT_THEME.getInactiveControlTextColor();// getControlDisabled()
		
		private final ColorUIResource inactiveSystemTextColor = DEFAULT_THEME.getInactiveSystemTextColor();// Sec
																											// 2
		
		private final ColorUIResource menuBackground = DEFAULT_THEME.getMenuBackground();// Sec 3
		
		private final ColorUIResource menuDisabledForeground = DEFAULT_THEME.getMenuDisabledForeground();// Sec
																											// 2
		
		private final ColorUIResource menuForeground = DEFAULT_THEME.getMenuForeground();// getBlack()
		
		private final ColorUIResource menuSelectedBackground = DEFAULT_THEME.getMenuSelectedBackground();// Pri
																											// 2
		
		private final ColorUIResource menuSelectedForeground = DEFAULT_THEME.getMenuSelectedForeground();// getBlack()
		
		private final FontUIResource menuTextFont = DEFAULT_THEME.getMenuTextFont();
		
		private final ColorUIResource primaryControl = DEFAULT_THEME.getPrimaryControl();// Pri3
		
		private final ColorUIResource primaryControlDarkShadow = DEFAULT_THEME.getPrimaryControlDarkShadow();// Pri
																												// 1
		
		private final ColorUIResource primaryControlHighlight = DEFAULT_THEME.getPrimaryControlHighlight();// getWhite()
		
		private final ColorUIResource primaryControlInfo = DEFAULT_THEME.getPrimaryControlInfo();// getBlack()
		
		private final ColorUIResource primaryControlShadow = DEFAULT_THEME.getPrimaryControlShadow();// Pri
																										// 2
		
		private final ColorUIResource separatorBackground = DEFAULT_THEME.getSeparatorBackground();// getWhite()
		
		private final ColorUIResource separatorForeground = DEFAULT_THEME.getSeparatorForeground();// Pri
																									// 1
		
		private final FontUIResource subTextFont = DEFAULT_THEME.getSubTextFont();
		
		private final ColorUIResource systemTextColor = DEFAULT_THEME.getSystemTextColor();// getBlack()
		
		private final FontUIResource systemTextFont = DEFAULT_THEME.getSystemTextFont();
		
		private final ColorUIResource textHighlightColor = DEFAULT_THEME.getTextHighlightColor();// Pri
																									// 3
		
		private final ColorUIResource userTextColor = DEFAULT_THEME.getUserTextColor();// getBlack()
		
		private final FontUIResource userTextFont = DEFAULT_THEME.getUserTextFont();
		
		private final ColorUIResource windowBackground = DEFAULT_THEME.getWindowBackground();// getWhite()
		
		private final ColorUIResource windowTitleBackground = DEFAULT_THEME.getWindowTitleBackground();// Pri
																										// 3
		
		private final FontUIResource windowTitleFont = DEFAULT_THEME.getWindowTitleFont();
		
		private final ColorUIResource windowTitleForeground = DEFAULT_THEME.getWindowTitleForeground();// getBlack()
		
		private final ColorUIResource windowTitleInactiveBackground = DEFAULT_THEME.getWindowTitleInactiveBackground();// Sec
																														// 3
		
		private final ColorUIResource windowTitleInactiveForeground = DEFAULT_THEME.getWindowTitleInactiveForeground();// getBlack()
		
		@Override
		public ColorUIResource getAcceleratorForeground() {
		
			return acceleratorForeground;
		}
		
		@Override
		public ColorUIResource getAcceleratorSelectedForeground() {
		
			return acceleratorSelectedForeground;
		}
		
		@Override
		public ColorUIResource getControl() {
		
			return control;
		}
		
		@Override
		public ColorUIResource getControlDarkShadow() {
		
			return controlDarkShadow;
		}
		
		@Override
		public ColorUIResource getControlDisabled() {
		
			return controlDisabled;
		}
		
		@Override
		public ColorUIResource getControlHighlight() {
		
			return controlHighlight;
		}
		
		@Override
		public ColorUIResource getControlInfo() {
		
			return controlInfo;
		}
		
		@Override
		public ColorUIResource getControlShadow() {
		
			return controlShadow;
		}
		
		@Override
		public ColorUIResource getControlTextColor() {
		
			return controlTextColor;
		}
		
		@Override
		public FontUIResource getControlTextFont() {
		
			return controlTextFont;
		}
		
		@Override
		public ColorUIResource getDesktopColor() {
		
			return desktopColor;
		}
		
		@Override
		public ColorUIResource getFocusColor() {
		
			return focusColor;
		}
		
		@Override
		public ColorUIResource getHighlightedTextColor() {
		
			return highlightedTextColor;
		}
		
		@Override
		public ColorUIResource getInactiveControlTextColor() {
		
			return inactiveControlTextColor;
		}
		
		@Override
		public ColorUIResource getInactiveSystemTextColor() {
		
			return inactiveSystemTextColor;
		}
		
		@Override
		public ColorUIResource getMenuBackground() {
		
			return menuBackground;
		}
		
		@Override
		public ColorUIResource getMenuDisabledForeground() {
		
			return menuDisabledForeground;
		}
		
		@Override
		public ColorUIResource getMenuForeground() {
		
			return menuForeground;
		}
		
		@Override
		public ColorUIResource getMenuSelectedBackground() {
		
			return menuSelectedBackground;
		}
		
		@Override
		public ColorUIResource getMenuSelectedForeground() {
		
			return menuSelectedForeground;
		}
		
		@Override
		public FontUIResource getMenuTextFont() {
		
			return menuTextFont;
		}
		
		@Override
		public String getName() {
		
			return Default.class.getSimpleName();
		}
		
		@Override
		public ColorUIResource getPrimaryControl() {
		
			return primaryControl;
		}
		
		@Override
		public ColorUIResource getPrimaryControlDarkShadow() {
		
			return primaryControlDarkShadow;
		}
		
		@Override
		public ColorUIResource getPrimaryControlHighlight() {
		
			return primaryControlHighlight;
		}
		
		@Override
		public ColorUIResource getPrimaryControlInfo() {
		
			return primaryControlInfo;
		}
		
		@Override
		public ColorUIResource getPrimaryControlShadow() {
		
			return primaryControlShadow;
		}
		
		@Override
		public ColorUIResource getSeparatorBackground() {
		
			return separatorBackground;
		}
		
		@Override
		public ColorUIResource getSeparatorForeground() {
		
			return separatorForeground;
		}
		
		@Override
		public FontUIResource getSubTextFont() {
		
			return subTextFont;
		}
		
		@Override
		public ColorUIResource getSystemTextColor() {
		
			return systemTextColor;
		}
		
		@Override
		public FontUIResource getSystemTextFont() {
		
			return systemTextFont;
		}
		
		@Override
		public ColorUIResource getTextHighlightColor() {
		
			return textHighlightColor;
		}
		
		@Override
		public ColorUIResource getUserTextColor() {
		
			return userTextColor;
		}
		
		@Override
		public FontUIResource getUserTextFont() {
		
			return userTextFont;
		}
		
		@Override
		public ColorUIResource getWindowBackground() {
		
			return windowBackground;
		}
		
		@Override
		public ColorUIResource getWindowTitleBackground() {
		
			return windowTitleBackground;
		}
		
		@Override
		public FontUIResource getWindowTitleFont() {
		
			return windowTitleFont;
		}
		
		@Override
		public ColorUIResource getWindowTitleForeground() {
		
			return windowTitleForeground;
		}
		
		@Override
		public ColorUIResource getWindowTitleInactiveBackground() {
		
			return windowTitleInactiveBackground;
		}
		
		@Override
		public ColorUIResource getWindowTitleInactiveForeground() {
		
			return windowTitleInactiveForeground;
		}
	}
	
	/**
	 * This class describes a theme using glowing green colors.
	 * 
	 * @author Jeff Dinkins
	 */
	public final class Emerald extends DefaultMetalTheme {
		
		private final ColorUIResource primary1 = new ColorUIResource(51, 142, 71);
		
		private final ColorUIResource primary2 = new ColorUIResource(102, 193, 122);
		
		private final ColorUIResource primary3 = new ColorUIResource(153, 244, 173);
		
		@Override
		protected ColorUIResource getPrimary1() {
		
			return primary1;
		}
		
		@Override
		protected ColorUIResource getPrimary2() {
		
			return primary2;
		}
		
		@Override
		protected ColorUIResource getPrimary3() {
		
			return primary3;
		}
		
		@Override
		public String getName() {
		
			return Emerald.class.getSimpleName();
		}
		
	}
	
	/**
	 * This class describes a theme using red colors.
	 * 
	 * @author Jeff Dinkins
	 */
	public final class Ruby extends DefaultMetalTheme {
		
		private final ColorUIResource primary1 = new ColorUIResource(80, 10, 22);
		
		private final ColorUIResource primary2 = new ColorUIResource(193, 10, 44);
		
		private final ColorUIResource primary3 = new ColorUIResource(244, 10, 66);
		
		@Override
		protected ColorUIResource getPrimary1() {
		
			return primary1;
		}
		
		@Override
		protected ColorUIResource getPrimary2() {
		
			return primary2;
		}
		
		@Override
		protected ColorUIResource getPrimary3() {
		
			return primary3;
		}
		
		@Override
		public String getName() {
		
			return Ruby.class.getSimpleName();
		}
	}
	
	/**
	 * This class describes a theme using red colors.
	 * 
	 * @project UtilsClasses
	 * @author Denilson Edinaldo Pinto
	 * @date 16/11/2011
	 */
	public final class Steel extends DefaultMetalTheme {
		
		@Override
		public String getName() {
		
			return Steel.class.getSimpleName();
		}
	}
}
